package vue;

import vue.ListenerButtonCheck;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.toedter.calendar.JCalendar;
 
public class MainFrame extends JFrame {
 


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private JPanel _panelNorth = new JPanel();
	
	private JPanel _panel = new JPanel();
	
	private JPanel _panelCentrale = new JPanel();
	
	private JPanel _panelDate = new JPanel();
    
	private JPanel _panelValider = new JPanel();
	
	private JButton _button = new JButton("Check");
	
	private float _durationMonths = 0;
	
    public JCalendar _cal1, _cal2 ;
	
	public JComboBox _jcbCheckStatus;
	
	public JComboBox _jcbCreditStory;
	
	public JComboBox _jcbPurpose;
	
	public JComboBox _jcbSavingStatus;
	
	public JComboBox _jcbEmployement;
	
	public JComboBox _jcbPersonnalStatus;
	
	public JComboBox _jcbOtherParties;
	
	public JComboBox _jcbPropertyMagnitude;
	
	public JComboBox _jcbOtherPayementPlan;
	
	public JComboBox _jcbHousing;
	
	public JComboBox _jcbJob;
	
	public JComboBox _jcbOwnTelephone;
	
	public JComboBox _jcbForeignWorker;
	
	public JTextField _jtfCreditAmount = new JTextField();
	
	public JTextField _jtfInstallmentCommitment = new JTextField();
	
	public JTextField _jtfResidence = new JTextField();
	
	public JTextField _jtfAge = new JTextField();
	
	public JTextField _jtfExistingCredit = new JTextField();
	
	public JTextField _jtfNum = new JTextField();
	
    public MainFrame()  {
 
    	this.setTitle("Software check solvability Customers");
            
        this.setLayout(new BorderLayout());
               
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        this.setResizable(false);
 
        this.setSize(850,500);
        
        this.setLocationRelativeTo(null);
        
        String contentCheckStatus[] = {"<0", "0<=X<200", ">=200", "no checking"};
        
        _jcbCheckStatus = new JComboBox(contentCheckStatus);
        
        String contentCreditHistory[] = {"no credits/all paid", "all paid", "existing paid", "delayed previously", "critical/other existing credit"};
  
        _jcbCreditStory = new JComboBox(contentCreditHistory);
        
        String contentPurpose[] = {"new car", "used car", "furniture/equipment", "radio/tv", "domestic appliance", "repairs", "education", "vacation", "retraining", "business", "other"};
        
        _jcbPurpose = new JComboBox(contentPurpose);
        
        String contentSavingStatus[] = {"<100", "100<=X<500", "500<=X<1000", ">=1000", "no known savings"};
        
        _jcbSavingStatus = new JComboBox(contentSavingStatus);
        
        String contentEmployement[] = {"unemployed", "<1", "1<=X<4", "4<=X<7", ">=7"};
        
        _jcbEmployement = new JComboBox(contentEmployement);
        
        String contentPersonalStatus[] = {"male div/sep", "female div/dep/mar", "male single", "male mar/wid", "female single"};
        
        _jcbPersonnalStatus = new JComboBox(contentPersonalStatus);
        
        String contentOtherParties[] = {"none", "co applicant", "guarantor"};
        
        _jcbOtherParties = new JComboBox(contentOtherParties);
        
        String contentPropertyMagnitude[] = {"real estate", "life insurance", "car", "no known property"};
        
        _jcbPropertyMagnitude = new JComboBox(contentPropertyMagnitude);
        
        String contentOtherPaymentPlan[] = { "bank", "stores", "none"};
        
        _jcbOtherPayementPlan = new JComboBox(contentOtherPaymentPlan);
        
        String contentHousing[] = {"rent", "own", "for free"};
        
        _jcbHousing = new JComboBox(contentHousing);
        
        String contentJob[] = {"unemp/unskilled non res", "unskilled resident", "skilled", "high qualif/self emp/mgmt"};
        
        _jcbJob = new JComboBox(contentJob);
        
        String contentOwnTelephone[] = {"none", "yes"};
        
        _jcbOwnTelephone = new JComboBox(contentOwnTelephone);
        
        String contentForeignWorker[] = {"yes","no"};
        
        _jcbForeignWorker = new JComboBox(contentForeignWorker);
        
        
        
        _panelNorth.setLayout(new GridLayout(14,2));
        
        _panel.setLayout(new GridLayout(2,1));
        
        _panelCentrale.setLayout(new GridLayout(8,2));
        
        _panelDate.setLayout(new GridLayout(2,2));
        
        _panelValider.setLayout(new GridLayout(2,3));
        
        
        
        
        _panelNorth.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK),""));
        _panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK),""));
        _panelValider.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLACK),""));
        
        
        
        _panelNorth.add(new JLabel("Check status : "));
        _panelNorth.add(_jcbCheckStatus);   
        _panelNorth.add(new JLabel("Credit History : "));
        _panelNorth.add(_jcbCreditStory);
        _panelNorth.add(new JLabel("Purpose : "));
        _panelNorth.add(_jcbPurpose);
        _panelNorth.add(new JLabel("Saving status : "));
        _panelNorth.add(_jcbSavingStatus);   
        _panelNorth.add(new JLabel("Employement : "));
        _panelNorth.add(_jcbEmployement);
        _panelNorth.add(new JLabel("Personal status : "));
        _panelNorth.add(_jcbPersonnalStatus);
        _panelNorth.add(new JLabel("Other parties : "));
        _panelNorth.add(_jcbOtherParties);   
        _panelNorth.add(new JLabel("Property magnitude : "));
        _panelNorth.add(_jcbPropertyMagnitude);
        _panelNorth.add(new JLabel("Other payement plan : "));
        _panelNorth.add(_jcbOtherPayementPlan);
        _panelNorth.add(new JLabel("Housing : "));
        _panelNorth.add(_jcbHousing);   
        _panelNorth.add(new JLabel("Job : "));
        _panelNorth.add(_jcbJob);
        _panelNorth.add(new JLabel("Own telephone : "));
        _panelNorth.add(_jcbOwnTelephone);
        _panelNorth.add(new JLabel("Foreign worker : "));
        _panelNorth.add(_jcbForeignWorker);   

        _button.addActionListener(new ListenerButtonCheck(this));
        
        // To calculate the duration
        _cal1 = new JCalendar() ;
        _cal2 = new JCalendar() ;
        
        _panelDate.add(new JLabel("Begining date : "));
        _panelDate.add(_cal1);
        _panelDate.add(new JLabel("Ending date : "));
        _panelDate.add(_cal2);
        
        _jtfCreditAmount.setText("0");
        _jtfInstallmentCommitment.setText("0");
        _jtfResidence.setText("0");
        _jtfAge.setText("0");
        _jtfExistingCredit.setText("0");
        _jtfNum.setText("0");
        
        _panelCentrale.add(new JLabel("Credit amount : "));
        _panelCentrale.add(_jtfCreditAmount);
        _panelCentrale.add(new JLabel("Installment commitment : "));
        _panelCentrale.add(_jtfInstallmentCommitment);
        _panelCentrale.add(new JLabel("Residence since : "));
        _panelCentrale.add(_jtfResidence);
        _panelCentrale.add(new JLabel("Age : "));
        _panelCentrale.add(_jtfAge);
        _panelCentrale.add(new JLabel("Existing credits : "));
        _panelCentrale.add(_jtfExistingCredit);
        _panelCentrale.add(new JLabel("Num depedents : "));
        _panelCentrale.add(_jtfNum);
        _panelCentrale.add(new JLabel(""));
        _panelCentrale.add(_button);

        _panelValider.add(new JLabel());
        _panelValider.add(_button);
        _panelValider.add(new JLabel());
        _panelValider.add(new JLabel());
        _panelValider.add(new JLabel());
        _panelValider.add(new JLabel());
        
        _panel.add(_panelDate);
        _panel.add(_panelCentrale);
        
        this.add("North",new JPanel());
        this.add("West",_panelNorth);
        this.add("East",_panel);
        this.add("South",_panelValider);
        
        
    }
 
    public void setDuration(float p_months){
    	_durationMonths = p_months;
    }
 
    public float getDuration(){
    	return _durationMonths;
    }
    
}